#!/bin/bash

# docker 常用软件安装
#
#


# 官方网站无法访问, 用其他网站的
#PRE=""
PRE=docker.m.daocloud.io/

# 基础路径
BASE_PATH=/opt/
echo "docker 所有容器默认安装在${BASE_PATH}下, 是否需要修改(Y/N):"
if [ $BASE_PATH == "y" ]; then
	echo "yes"
	read CUSTOM_PATH
fi

echo "============ 开始安装portainer ...  ============"

#docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always  -v portainer_data:/data -v /var/run/docker.sock:/var/run/docker.sock   ${PRE}portainer/portainer-ce



echo "============ 开始安装nginx ...  ============"

#docker run -p 80:80 --name nginx  -v ${BASE_PATH}nginx/conf/conf.d:/etc/nginx/conf.d  -v ${BASE_PATH}nginx/log:/var/log/nginx  -v ${BASE_PATH}nginx/html:/usr/share/nginx/html  -d ${PRE}nginx:latest



echo "============ 开始安装rocketmq ...  ============"
# 配置 rocketmq 多模块通信网络
docker network create rocketmq
# 启动 NameServer
docker run -d --name rmqnamesrv -p 9876:9876 --network rocketmq ${PRE}apache/rocketmq:5.3.1 sh mqnamesrv

# 验证 NameServer 是否启动成功
#docker logs -f rmqnamesrv


mkdir -p ${BASE_PATH}rocketmq/conf/ && echo "brokerIP1=127.0.0.1" > ${BASE_PATH}rocketmq/conf/broker.conf

docker run -d \
--name rmqbroker \
--network rocketmq \
-p 10912:10912 -p 10911:10911 -p 10909:10909 \
-e "NAMESRV_ADDR=rmqnamesrv:9876" \
-v ${BASE_PATH}rocketmq/conf/broker.conf:/home/rocketmq/rocketmq-5.3.1/conf/broker.conf \
${PRE}apache/rocketmq:5.3.1 sh mqbroker --enable-proxy \
-c /home/rocketmq/rocketmq-5.3.1/conf/broker.conf


# 验证 Broker 是否启动成功
#docker exec -it rmqbroker bash -c "tail -n 10 /home/rocketmq/logs/rocketmqlogs/proxy.log"

# 安装TODO
#docker run -d \
#--link rmqnamesrv:namesrv \
#-e "JAVA_OPTS=-Drocketmq.config.namesrvAddr=namesrv:9876 -Drocketmq.config.isVIPChannel=false" \
#--name rmqconsole \
#-p 8088:8080 \
#-t ${PRE}apache/rocketmq-console-ng:1.0.0



echo "============ 开始安装nacos ...  ============"
sudo docker run -d -p 8848:8848  --name nacos -e MODE=standalone -e TIME_ZONE='Asia/Shanghai' ${PRE}nacos/nacos-server:v2.5.0






























